﻿#if false
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;

public class UIRadioGroupHelper
{
    [MenuItem("GameObject/����Ĭ�� UI/����Ĭ�� UIRadioGroup/UIRadio", priority = -241)]
    public static void CreateUIRadio()
    {
        if (Selection.activeTransform)
        {
            GameObject radio = new GameObject("UIRadio");
            radio.AddComponent<RectTransform>();
            var img=  radio.AddComponent<Image>();
           
            var comp=  radio.AddComponent<UIRadio>();

            radio.transform.SetParent(Selection.activeTransform, false);
            Selection.activeTransform = radio.transform;

            _CreateUIRadio(radio, "DisSelect",out comp._DisSelectObj,out comp._DisSelectImage, out comp._DisSelectTxt);
            _CreateUIRadio(radio, "Select", out comp._SelectObj, out comp._SelectImage, out comp._SelectTxt);

            Selection.activeTransform = radio.transform;
        }
    }

    private static void _CreateUIRadio(GameObject parent, string name,out GameObject container,out Image img,out Text txt)
    {
        container = new GameObject($"Go_{name}");
        container.AddComponent<RectTransform>();
        container.transform.SetParent(parent.transform);
        container.transform.localPosition = Vector3.zero;

        GameObject imgGo = new GameObject($"Img_{name}", typeof(Image));
        imgGo.transform.SetParent(container.transform);
        imgGo.transform.localPosition = Vector3.zero;
        imgGo.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);

        img = imgGo.GetComponent<Image>();
        img.raycastTarget = false;

        GameObject txtGo = new GameObject($"Txt_{name}", typeof(Text));
        txtGo.transform.SetParent(container.transform);
        txtGo.transform.localPosition = Vector3.zero;
        txtGo.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);

        txt = txtGo.GetComponent<Text>();
        txt.raycastTarget = false;
        txt.alignment = TextAnchor.MiddleCenter;
        txt.horizontalOverflow = HorizontalWrapMode.Overflow;
        txt.verticalOverflow = VerticalWrapMode.Overflow;

        txtGo.AddComponent<Outline>();
    }


    [MenuItem("GameObject/����Ĭ�� UI/����Ĭ�� UIRadioGroup/UIRadio", true)]
    public static bool CreateButtonValidate()
    {
        return Selection.activeTransform != null;
    }

    #region ����UIRadioGroup

    [MenuItem("GameObject/����Ĭ�� UI/����Ĭ�� UIRadioGroup/UIRadioGroup ", priority = -242)]
    public static void CreateUIRadioGroup()
    {
        if (Selection.activeTransform)
        {
            GameObject radioGroup = new GameObject("UIRadioGroup");
            radioGroup.AddComponent<UIRadioGroup>();
            radioGroup.AddComponent<RectTransform>();
            radioGroup.transform.SetParent(Selection.activeTransform, false);

            Selection.activeTransform = radioGroup.transform;
        }
    }

    [MenuItem("GameObject/����Ĭ�� UI/����Ĭ�� UIRadioGroup/UIRadio", true)]
    public static bool CreateUIRadioGroupValidate()
    {
        return Selection.activeTransform != null;
    }


    [MenuItem("GameObject/����Ĭ�� UI/����Ĭ�� UIRadioGroup/UIRadioGroup Parent", priority = -243)]
    public static void CreateUIRadioGroupParent()
    {
        // ��ȡ��ǰѡ������� GameObject
        GameObject[] selectedObjects = Selection.gameObjects;

        // ���û��ѡ���κζ����򷵻�
        if (selectedObjects.Length == 0)
        {
            Debug.LogWarning("No GameObjects selected.");
            return;
        }

        // ����һ���µĿ� GameObject ��Ϊ���ڵ�
        GameObject radioGroup = new GameObject("UIRadioGroup");
        radioGroup.AddComponent<RectTransform>();
        var radioGroupComp = radioGroup.AddComponent<UIRadioGroup>();
        GameObject child = selectedObjects[0];
        radioGroup.transform.SetParent(child.transform.parent.transform, false);

        // ��ѡ�е����ж�����Ϊ�´��� GameObject ���Ӷ���
        foreach (GameObject obj in selectedObjects)
        {
            obj.transform.SetParent(radioGroup.transform);
        }

        Selection.activeTransform = radioGroup.transform;

        //��������Group
        int childCount = radioGroup.transform.childCount;
        for (int index = 0; index < childCount; index++)
        {
            var ele = radioGroup.transform.GetChild(index);
            var comp = ele.GetComponent<UIRadio>();
            if (comp == null)
            {
                continue;
            }

            comp.RadioGroup = radioGroupComp;
        }

        // ѡ���´����ĸ�����
        Selection.activeGameObject = radioGroup;
    }


    [MenuItem("GameObject/����Ĭ�� UI/����Ĭ�� UIRadioGroup/UIRadioGroup Parent", true)]
    public static bool CreateUIRadioGroupParentValidate()
    {
        return Selection.activeTransform != null;
    }

    #endregion
}
#endif